<%@ include file="/jsp/common.jsp" %>
<%@ page  language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<head>
<link href="../../css/mainbody_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/jquery-1.4.4.js" ></script>
<style type="text/css" >
	#resContentTable{border-top:solid 1px black; border-left:solid 1px black;}
	#resContentTable td{border-bottom:solid 1px black;border-right:solid 1px;}
	#resContentTable tr:nth-child(2n){background-color:#eee;}
</style>
</head>
<body>
	<div style="width:90%;">
		<form id="newForm" method="post">
			<input type="hidden" name="position" value="<c:out value='${position}'/>" />
			<table style="width:90%;table-layout:fixed;line-height:4em;">
				<tr>
					<td style="text-align:right;">学校:</td>
					<td>
						<input type="text" disabled="disabled"  style="color:blue;background-color:#f4f4f4;font-size:1.1em;"
						name="schoolName" value="<c:out value='${schoolName}'/>" />
					</td>
					<td style="text-align:right;">年级:</td>
					<td>
						<select  name="gradeCode" id="gradeCode" style="width:80%;height:1.5em;">
							<option value="">--请选择--
							<c:forEach items="${gradeList}" var="grade">
								<option value="<c:out value='${grade.dicCode}'/>"> <c:out value="${grade.dicValue }"/> 
							</c:forEach>
						</select>
					</td>
					<td>
						<input type="button" class="button_sub01" value="查询" onclick="queryGradeInfo();"/>
					</td>
				</tr>
			</table>
		</form>
	</div>
	
	<div style="width:90%;display:none;" id="resultPald">
		<table style="width:90%;line-height:3em;margin-left:10%;text-align:center;" id="resContentTable" >
			<tr id="trHeadId">
				<td>年级</td>
				<td>班级</td>
				<td>班主任</td>
				<td>电话</td>
				<td>科目/类别</td>
			</tr>
		</table>
	</div>
	
	<script>
		function queryGradeInfo(){
			while($("#trHeadId").next().html()){
				$("#trHeadId").next().remove();
			};
			$("#resultPald").css("display","block");
			$.ajax({
				url:"queryDetailGradeInfo.do",
				type:"post",
				async:true,
				dataType:"text",
				data:$("#newForm").serialize(),
				success:function(data){
					var resList = eval("("+data+")");
					if(resList.length){
						for(var ind in resList){
							var content = "<tr><td>"+resList[ind]["gradeName"]+"</td><td>"
											+resList[ind]["className"]+"班</td><td>"
											+resList[ind]["teacherName"]+"</td><td>"
											+resList[ind]["telPhone"]+"</td><td>"
											+resList[ind]["majorType"]+"</td></tr>" ;
							$(content).appendTo("#resContentTable");	// 或者 $("#resContentTable").append(content);
						};
					}else{
						var content = "<tr><td colspan=6>无符合条件查询结果</td></tr>" ;
						$(content).appendTo("#resContentTable");
					}
				},
				error:function(data){
					var resList = data;
					alert("查询失败");
				}
			});
			
		}
	</script>
</body>